package com.sun.showcase.controller.app.mall;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.sun.showcase.biz.mall.service.OrderReturnService;
import com.sun.showcase.client.query.mall.OrderReturnQuery;
import com.sun.showcase.client.vo.order.ReturnOrderEntity;
import com.sun.showcase.pojo.DataGrid;
import com.sun.showcase.pojo.Result;
import com.sun.showcase.utils.ExecuteResult;
@CrossOrigin
@RestController("appOrderReturnController")
@RequestMapping(value="/app/orderReturn") 
public class OrderReturnController{
	
	@Autowired
	private OrderReturnService orderReturnService;
	
	private Result result = new Result();
	@RequestMapping(value="save")
	public Result save(ReturnOrderEntity entity) {
		ExecuteResult<String> exe = orderReturnService.save(entity);
		result.setSuccess(exe.isSuccess());
		if(exe.isSuccess()) {
			result.setMsg(exe.getSuccessMessage());
		}else {
			result.setMsg(exe.getErrorMessages().get(0));
		}
		return result;
	}
	/**
	 * 全部数据OrderReturn
	 */
	@RequestMapping(value="list")
	public Result list(String userId) {
		OrderReturnQuery orderReturnQuery = new OrderReturnQuery();
		orderReturnQuery.setUserId(userId);
		orderReturnQuery.setOrderColum("create_date");
		orderReturnQuery.setOrderRule("DESC");
		DataGrid dg = orderReturnService.datagrid(orderReturnQuery);
		result.setSuccess(true);
		result.setMsg("成功！");
		result.setData(dg);
		return result;
	}
}
